import junit.framework.TestCase;
/**
 * Test cases for SkipList
 * @author Matt
 *
 */
public class SkipListTest extends TestCase {

	@SuppressWarnings("unused")
	public void testNames() {
		SkipList<String> list = new SkipList<String>(new TestRandom());

		SkipListHead<String> head = new SkipListHead<String>();
		list.setTopLeft(head);
		head = list.getTopLeft();

		SkipListTail<String> tail = new SkipListTail<String>();
		list.setTopRight(tail);
		tail = list.getTopRight();

		list.setHeight(4);
		int height = list.getHeight();

		list.setSize(4);
		int size = list.size();
	}
	
	public void testAdd()
	{
		SkipList<Integer> list = new SkipList<Integer>(new TestRandom());
		list.add(5);
		list.add(5);
		list.add(6);
		list.add(9);
		list.add(25);
		list.add(2);
		list.add(7);
		assertTrue(list.contains(9));
		assertTrue(list.contains(7));
		assertTrue(list.contains(25));
		assertFalse(list.contains(100));
		
	}
	
		
	
	
	public void testRemove()
	{

		SkipList<Integer> list = new SkipList<Integer>(new TestRandom());
		list.add(5);
		list.add(5);
		list.add(6);
		list.add(9);
		list.add(25);
		list.add(2);
		list.add(7);
		Integer element = list.remove(9);
		assertFalse(list.contains(9));
		assertEquals((Integer)9,element);
		Integer element1 = list.remove(7);
		assertFalse(list.contains(7));
		assertEquals((Integer)7,element1);
	}
	public void testOthers()
	{
		SkipList<Integer> list = new SkipList<Integer>(new TestRandom());
		list.add(5);
		list.add(6);
		list.add(9);
		list.add(25);
		list.add(2);
		list.add(7);
		Integer minElement = list.getMin();
		assertEquals(minElement,(Integer)2);
		
		Integer maxElement = list.getMax();
		assertEquals(maxElement,(Integer)25);
		
		int index1 = list.indexOf(7);
		assertEquals(index1,4);
		
		int index2 = list.indexOf(8);
		assertEquals(index2,-5);
		
		int size = list.size();
		assertEquals(size,6);
		
		list.remove(2);
		
		size = list.size();
		assertEquals(size,5);
		
		assertFalse(list.isEmpty());
		
		list.clear();
		assertTrue(list.isEmpty());
		
	}
}
